package com.sy.core.service;

import com.sy.core.mapper.SyReceiverMessageMapper;
import com.sy.core.model.SyReceiverMessage;
import com.sy.core.web.BaseCtl;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.helper.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class AddressService extends BaseCtl {
    @Autowired
    private SyReceiverMessageMapper syReceiverMessageMapper;
   public List<Map<String,Object>> queryList(SyReceiverMessage syReceiverMessage){
        syReceiverMessage.setNo1("N");
        return syReceiverMessageMapper.queryList(syReceiverMessage);
   }

    public Integer addressAddAndEdit(SyReceiverMessage syReceiverMessage) {
       if(StringUtils.isNotBlank(syReceiverMessage.getPk())){
           syReceiverMessage.setReceiverPk(getLoginUserPk());
           return syReceiverMessageMapper.updateByPrimaryKey(syReceiverMessage);
       }else{
           syReceiverMessage.setPk(getPrimaryKey());
           syReceiverMessage.setReceiverPk(getLoginUserPk());
           return syReceiverMessageMapper.insertSelective(syReceiverMessage);
       }
    }

    public Map<String,Object> queryOne(String pk) {
       return syReceiverMessageMapper.queryOne(pk);
    }

    public Integer delete(String pk) {
       return syReceiverMessageMapper.deleteByPrimaryKey(pk);
    }
}
